
'''
142. 环形链表 II
'''
from typing import Optional

from com.siyuan.ListNode import ListNode


class Solution:
    def hasCycle(self, head: Optional[ListNode]) -> bool:
        fast = head
        slow = head
        while fast and fast.next:
            fast = fast.next.next
            slow = slow.next
            if fast == slow:
                return True
        return False

if __name__ == '__main__':
    sl = Solution()